package com.flying.learning.exporter;

import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CustomCollector2 extends Collector {
    @Override
    public List<MetricFamilySamples> collect() {
        List<MetricFamilySamples> mfs = new ArrayList<>();
        // with no labels
        mfs.add(new GaugeMetricFamily("my_gauge_2", "help", 42));

        // with labels
        GaugeMetricFamily labeledGuage = new GaugeMetricFamily("my_other_gauge", "help", Arrays.asList("labelname"));
        labeledGuage.addMetric(Arrays.asList("foo"), 4);
        labeledGuage.addMetric(Arrays.asList("bar"), 5);
        mfs.add(labeledGuage);
        return mfs;
    }
}
